package bean.config;

import bean.dao.impl.UserDaoImpl;
import bean.domain.Account;
import bean.domain.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author peter
 * @date 2021/12/4 上午2:19
 */
@Configuration
// @Scope("prototype") // 设置Bean作用域
public class AccountConfig {

    @Bean(name = "accountCustom")
    // @Scope("prototype") // 设置Bean作用域
    public Account account() {
        Account account = new Account();
        account.setId(1);
        account.setUsername("peter");
        return account;
    }

    public AccountConfig(){
        System.out.println("AccountConfig constructor");
    }

    @PostConstruct
    public void init() {
        System.out.println("AccountConfig PostConstruct init method");
    }

    @PreDestroy
    public void destory() {
        System.out.println("AccountConfig destory method");
    }
}
